|
RAIS
3.2
|
00001 using System; 00002 using System.Collections.Generic; 00003 using System.Linq; 00004 using System.Web; 00005 using System.Web.UI; 00006 using System.Web.UI.WebControls; 00007 00008 //using FunctionRoles = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.FunctionRole>; 00009 using DataRoles = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.DataRole>; 00010 using Facilities = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.Facility>; 00011 using UserTypes = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.UserTypeData>; 00012 using Regions = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.Region>; 00013 using Districts = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.District>; 00014 using Practices = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.Practice>; 00015 using RAIS.Common.UserManagement; 00016 using MessageBoxRestrictions = System.Collections.Generic.List<RAIS.Common.UserManagement.MessageBoxRestriction>; 00017 00018 namespace RAIS.UI.SpecificMasks 00019 { 00020 public partial class MessageBoxConfiguration : System.Web.UI.Page 00021 { 00022 public enum PageMode 00023 { 00024 viewUserPerm, 00025 addUserPerm, 00026 editUserPerm 00027 }; 00028 00029 #region eventhandlers 00030 protected void Page_PreLoad(object sender, EventArgs e) 00031 { 00032 RAIS.UI.Common.PageManagement.TrimTextBoxValues(this); 00033 } 00034 00035 protected void Page_Load(object sender, EventArgs e) 00036 { 00037 this.Response.Cache.SetNoStore(); 00038 if (this.CurrentUser == null) 00039 UI.Common.AccessManagement.SignOut(this); 00040 00041 this.LBLresult.Text = string.Empty; 00042 00043 if (!this.IsPostBack) 00044 { 00045 DDLyesNo.Items.Add(RAIS.ApplicationLogicLayer.Localisation.Translate("No", "ASP.messageboxconfiguration_aspx", RAIS.Common.Constants.DEFAULT_LANGUAGE, this.CurrentUser.Language)); 00046 DDLyesNo.Items.Add(RAIS.ApplicationLogicLayer.Localisation.Translate("Yes", "ASP.messageboxconfiguration_aspx", RAIS.Common.Constants.DEFAULT_LANGUAGE, this.CurrentUser.Language)); 00047 00048 this.BTNdelete.Attributes.Add("onclick", string.Format("javascript: return confirm('{0}');", RAIS.Common.Messages.DELETE_QUESTION_MESSAGEBOX_RESTRICTION.Replace("'", "\\'"))); 00049 this.CurrentPageMode = PageMode.viewUserPerm; 00050 this.LBLmessage.ForeColor = RAIS.UI.Common.Constants.COLOR_OF_MENU_BAR_TEXT_HIGHLIGHT; 00051 this.LBLusernameNoTranslation.Text = this.CurrentUser.Name; 00052 //this.CurrentPageMode = PageMode.viewRoles; 00053 this.LBLValidFromDescription.Text = UI.Common.DynamicMaskManagement.GetNationalDateFormatString(true); 00054 this.LBLValidUntilDescription.Text = UI.Common.DynamicMaskManagement.GetNationalDateFormatString(true); 00055 00056 //foreach (DataControlField gridColumn in this.GVuserpermissions.Columns) 00057 //{ 00058 // gridColumn.HeaderText = RAIS.ApplicationLogicLayer.Localisation.Translate(gridColumn.HeaderText 00059 // , this.ToString() 00060 // , RAIS.Common.Constants.DEFAULT_LANGUAGE 00061 // , this.CurrentUser.Language); 00062 //} 00063 UI.Common.Localisation.TranslateGridViewHeader(this.GVuserpermissions, this.ToString(), RAIS.Common.Constants.DEFAULT_LANGUAGE, this.CurrentUser.Language); 00064 00065 //UI.Common.UserManagement.InitializeUsersListBox(this.LBselecteduser); 00066 UI.Common.UserManagement.InitializeCustomUsersListBox(this.LBselecteduser, UI.Common.UserManagement.GetLevelThreeUsers().Values.ToList<UserData>()); 00067 00068 if (this.LBselecteduser.Items.Count >= 0) 00069 { 00070 if (this.Session[RAIS.UI.Common.Constants.SELECTED_USER_TAG] != null) 00071 { 00072 this.LBselecteduser.SelectedValue = ((UserData)this.Session[RAIS.UI.Common.Constants.SELECTED_USER_TAG]).Login; 00073 } 00074 else 00075 { 00076 this.LBselecteduser.SelectedIndex = 0; 00077 } 00078 00079 if (this.MessageBoxRestrictions != null) 00080 { 00081 this.InitializeGridView(); 00082 } 00083 else 00084 { 00085 this.GVuserpermissions.DataSource = new List<MessageBoxRestriction>(); 00086 this.GVuserpermissions.DataBind(); 00087 } 00088 this.GVuserpermissions.SelectedIndex = -1; 00089 } 00090 else 00091 { 00092 this.LBselecteduser.SelectedIndex = -1; 00093 } 00094 00095 00096 UI.Common.PageManagement.InitializePageTreeForCategory(this, this.TreeView1, RAIS.Common.Constants.CATEGORY_NAME_MESSAGEBOX); 00097 //UI.Common.PageManagement.InitializePage(this, this.TreeView1); 00098 this.TreeView1.ExpandAll(); 00099 } 00100 //UI.Common.Localisation.TranslatePage(this); 00101 UI.Common.PageManagement.InitHelpMainMenu(LBTNdefault); 00102 00103 } 00104 00110 protected void Page_Init(object sender, EventArgs e) 00111 { 00112 Common.PageManagement.SetScrolableListBox(this.LBselecteduser, this, true); 00113 } 00114 00115 protected void DDLyesNo_selectedIndexChanged(object sender, EventArgs e) 00116 { 00117 this.InitializeGridView(); 00118 } 00119 00126 protected void LBTNlogout_Click(object sender, EventArgs e) 00127 { 00128 UI.Common.AccessManagement.SignOut(this); 00129 } 00130 00137 protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e) 00138 { 00139 UI.Common.UserManagement.ProcessTreeViewOnRedirect(this.TreeView1); 00140 } 00141 00148 protected void LBMessageBoxConfigurationUsers_SelectedIndexChanged(object sender, EventArgs e) 00149 { 00150 /*** 00151 if (this.SelectedRole != null) 00152 { 00153 this.InitializeGridView(); 00154 } 00155 else 00156 { 00157 DataRole tempRole = new DataRole(); 00158 this.GVuserpermissions.DataSource = tempRole.Attributes.Values; 00159 this.GVuserpermissions.DataBind(); 00160 } 00161 00162 this.GVuserpermissions.SelectedIndex = -1; 00163 * 00164 * ****/ 00165 if (this.MessageBoxRestrictions != null) 00166 { 00167 this.InitializeGridView(); 00168 } 00169 else 00170 { 00171 this.GVuserpermissions.DataSource = new List<MessageBoxRestriction>(); 00172 this.GVuserpermissions.DataBind(); 00173 } 00174 } 00175 00182 protected void BTNadd_Click(object sender, EventArgs e) 00183 { 00184 this.CurrentPageMode = PageMode.addUserPerm; 00185 InitializeEditControls(); 00186 00187 00188 00189 //this.EnableDisableControls(); 00190 00191 // if no messageboxrestriction -> add one 00192 // if already mbr -> update 00193 00194 // add == edit 00195 00196 00197 00198 } 00205 protected void BTNedit_Click(object sender, EventArgs e) 00206 { 00207 this.CurrentPageMode = PageMode.editUserPerm; 00208 InitializeEditControls(); 00209 00210 00211 } 00218 protected void BTNdelete_Click(object sender, EventArgs e) 00219 { 00220 bool success = true; 00221 success = this.DeleteMessageBoxRestriction(); 00222 } 00229 protected void BTNdiscard_Click(object sender, EventArgs e) 00230 { 00231 this.CurrentPageMode = PageMode.viewUserPerm; 00232 } 00239 protected void BTNsave_Click(object sender, EventArgs e) 00240 { 00241 bool success = true; 00242 string message = String.Empty; 00243 00244 try 00245 { 00246 DateTime from = DateTime.Parse(this.TBValidFrom.Text); 00247 DateTime until = DateTime.Parse(this.TBValidUntil.Text); 00248 if (from > until) 00249 { 00250 success = false; 00251 message = RAIS.UI.Common.Constants.RESTRICTION_SAVE_DATE_FAIL; 00252 } 00253 } 00254 catch (Exception) 00255 { 00256 success = false; 00257 } 00258 00259 00260 if ((this.DDLpractice.SelectedValue.Equals(String.Empty) && 00261 this.DDLdmregion.SelectedValue.Equals(String.Empty) && 00262 this.DDLdmdistrict.SelectedValue.Equals(String.Empty) && 00263 this.DDLdmfacility.SelectedValue.Equals(String.Empty)) || !success) 00264 { 00265 message = String.Empty.Equals(message) ? RAIS.UI.Common.Constants.RESTRICTION_SAVE_FAIL : message; 00266 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult, 00267 message, 00268 false); 00269 } 00270 else 00271 { 00272 if (this.CurrentPageMode == PageMode.addUserPerm) 00273 { 00274 success = this.AddNewMessageBoxRestriction(); 00275 } 00276 if (this.CurrentPageMode == PageMode.editUserPerm) 00277 { 00278 success = this.EditMessageBoxRestriction(); 00279 } 00280 } 00281 } 00282 00289 protected void GVuserpermissions_RowCommand(object sender, GridViewCommandEventArgs e) 00290 { 00291 if (e.CommandName.Equals("Select")) 00292 { 00293 int rowIndex = Convert.ToInt32(e.CommandArgument); 00294 this.GVuserpermissions.SelectedIndex = rowIndex; 00295 this.EnableDisableControls(); 00296 } 00297 } 00298 00306 protected void DDLdmregion_SelectedIndexChanged(object sender, EventArgs e) 00307 { 00308 this.DDLdmdistrict.Items.Clear(); 00309 this.DDLdmfacility.Items.Clear(); 00310 00311 //UI.Common.UserManagement.InitializeDistrictsList(this.DDLdmdistrict, 00312 // this.DDLdmregion.SelectedValue); 00313 if (RAIS.Common.Constants.ALL_REGIONS == this.DDLdmregion.SelectedValue) 00314 UI.Common.UserManagement.InitializeDistrictsList(this.DDLdmdistrict, 00315 this.DDLdmregion.SelectedValue); 00316 else 00317 UI.Common.UserManagement.InitializeDistrictsListWithEmptyRow(this.DDLdmdistrict, 00318 this.DDLdmregion.SelectedValue); 00319 00320 00321 UI.Common.UserManagement.InitializeFacilitiesList(this.DDLdmfacility, 00322 this.DDLdmregion.SelectedValue, 00323 this.DDLdmdistrict.SelectedValue); 00324 if (RAIS.Common.Constants.ALL_DISTRICTS == this.DDLdmdistrict.SelectedValue) 00325 this.DDLdmfacility.SelectedValue = RAIS.Common.Constants.ALL_FACILITIES_UNKNOWN; 00326 this.filterFacilitiesByPractice(); 00327 } 00335 protected void DDLdmdistrict_SelectedIndexChanged(object sender, EventArgs e) 00336 { 00337 this.DDLdmfacility.Items.Clear(); 00338 UI.Common.UserManagement.InitializeFacilitiesList(this.DDLdmfacility, 00339 this.DDLdmregion.SelectedValue, 00340 this.DDLdmdistrict.SelectedValue); 00341 if (RAIS.Common.Constants.ALL_DISTRICTS == this.DDLdmdistrict.SelectedValue) 00342 this.DDLdmfacility.SelectedValue = RAIS.Common.Constants.ALL_FACILITIES_UNKNOWN; 00343 this.filterFacilitiesByPractice(); 00344 00345 } 00346 00347 protected void DDLpractice_SelectedIndexChanged(object sender, EventArgs e) 00348 { 00349 this.DDLdmfacility.Items.Clear(); 00350 UI.Common.UserManagement.InitializeFacilitiesList(this.DDLdmfacility, 00351 this.DDLdmregion.SelectedValue, 00352 this.DDLdmdistrict.SelectedValue); 00353 00354 this.filterFacilitiesByPractice(); 00355 } 00356 00357 #endregion 00358 00359 #region private helper 00360 00361 private void filterFacilitiesByPractice() 00362 { 00363 if(this.DDLpractice.SelectedValue != null && 00364 this.DDLpractice.SelectedValue != "" && 00365 !(this.DDLdmfacility.SelectedValue.Equals(RAIS.Common.Constants.ALL_FACILITIES) || this.DDLdmfacility.SelectedValue.Equals(RAIS.Common.Constants.ALL_FACILITIES_UNKNOWN))) 00366 { 00367 List<Facility> facs = ApplicationLogicLayer.UserManagement.getFacilitiesByPractice(RAIS.ApplicationLogicLayer.UserManagement.Practices[this.DDLpractice.SelectedValue].ID); 00368 00369 List<string> facsToDelete = new List<string>(); 00370 00371 foreach(ListItem item in this.DDLdmfacility.Items) 00372 { 00373 Facility inList = RAIS.ApplicationLogicLayer.UserManagement.Facilities[item.Text]; 00374 if (!facs.Contains(inList)) 00375 facsToDelete.Add(item.Text); 00376 } 00377 00378 foreach (string del in facsToDelete) 00379 { 00380 this.DDLdmfacility.Items.Remove(this.DDLdmfacility.Items.FindByText(del)); 00381 } 00382 } 00383 if (this.DDLpractice.SelectedValue != null && 00384 this.DDLpractice.SelectedValue != "" && 00385 (this.DDLdmregion.SelectedValue == null || this.DDLdmregion.SelectedValue.Equals(String.Empty)) && 00386 (this.DDLdmdistrict.SelectedValue == null || this.DDLdmdistrict.SelectedValue.Equals(String.Empty))) 00387 { 00388 Facility allFacs = RAIS.ApplicationLogicLayer.UserManagement.Facilities[RAIS.Common.Constants.ALL_FACILITIES_UNKNOWN]; 00389 this.DDLdmfacility.Items.Add(allFacs.Name); 00390 this.DDLdmfacility.SelectedValue = allFacs.Name; 00391 } 00392 if (this.DDLdmfacility.Items.Count >= 1 && 00393 this.DDLdmfacility.Items[0].Text != RAIS.Common.Constants.ALL_FACILITIES_UNKNOWN) 00394 this.DDLdmfacility.Items.Insert(0, new ListItem(string.Empty)); 00395 00396 } 00397 00401 private void EnableDisableControls() 00402 { 00403 //this.LBdma.Enabled = this.CurrentPageMode == PageMode.viewUserPerm; 00404 //this.LBdmrolename.Enabled = (this.CurrentPageMode == PageMode.viewUserPerm); 00405 this.GVuserpermissions.Enabled = (this.CurrentPageMode == PageMode.viewUserPerm);// || (this.CurrentPageMode == PageMode.editUserPerm); 00406 this.BTNadd.Enabled = (this.CurrentPageMode == PageMode.viewUserPerm); 00407 //this.BTNedit.Enabled = (this.CurrentPageMode == PageMode.viewUserPerm) && (this.SelectedRoleAttribute != null); 00408 //this.BTNdelete.Enabled = (this.CurrentPageMode == PageMode.viewUserPerm) && (this.SelectedRoleAttribute != null); 00409 this.BTNedit.Enabled = (this.CurrentPageMode == PageMode.viewUserPerm) && (this.SelectedRestriction != null); 00410 this.BTNdelete.Enabled = (this.CurrentPageMode == PageMode.viewUserPerm) && (this.SelectedRestriction != null); 00411 this.BTNsave.Enabled = !(this.CurrentPageMode == PageMode.viewUserPerm); 00412 this.BTNdiscard.Enabled = !(this.CurrentPageMode == PageMode.viewUserPerm); 00413 this.FSattributes.Visible = !(this.CurrentPageMode == PageMode.viewUserPerm); 00414 this.LBselecteduser.Enabled = (this.CurrentPageMode == PageMode.viewUserPerm); 00415 this.TBValidUntil.Enabled = (this.CurrentPageMode != PageMode.viewUserPerm); 00416 this.TBValidFrom.Enabled = (this.CurrentPageMode != PageMode.viewUserPerm); 00417 //this.TBValidUntil.Visible = (this.CurrentPageMode != PageMode.editUserPerm); 00418 //this.TBValidFrom.Visible = (this.CurrentPageMode != PageMode.editUserPerm); 00419 //this.LBLValidFrom.Enabled = (this.CurrentPageMode != PageMode.editUserPerm); 00420 //this.LBLValidUntil.Enabled = (this.CurrentPageMode != PageMode.editUserPerm); 00421 this.DDLyesNo.Enabled = (this.CurrentPageMode == PageMode.viewUserPerm); 00422 this.LBTakeOver.Enabled = (this.CurrentPageMode == PageMode.viewUserPerm); 00423 this.LBHistory.Enabled = (this.CurrentPageMode == PageMode.viewUserPerm); 00424 UI.Common.UserManagement.EnableCommonControls(this, (this.CurrentPageMode == PageMode.viewUserPerm)); 00425 UI.Common.UserManagement.ApplyAccessRights(this); 00426 } 00427 00431 protected void InitializeGridView() 00432 { 00433 //this.GVuserpermissions.DataSource = this.SelectedRole.Attributes.Values; 00434 00435 if (UI.Common.UserManagement.getActiveMessageBoxRestrictionsForUser(this.SelectedUser).Count < 1) 00436 this.GVuserpermissions.EmptyDataText = "This user has no restrictions"; 00437 else 00438 this.GVuserpermissions.EmptyDataText = "This user currently has no actual restrictions"; 00439 this.GVuserpermissions.DataSource = this.MessageBoxRestrictions; 00440 this.GVuserpermissions.DataBind(); 00441 this.GVuserpermissions.SelectedIndex = -1; 00442 } 00443 00447 private void InitializeEditControls() 00448 { 00449 if (this.CurrentPageMode == PageMode.addUserPerm) 00450 { 00451 this.TBValidFrom.Text = String.Empty; 00452 this.TBValidUntil.Text = String.Empty; 00453 } 00454 else if (this.CurrentPageMode == PageMode.editUserPerm) 00455 { 00456 char[] stripParenth = { '(', ')' }; 00457 string format = UI.Common.DynamicMaskManagement.GetNationalDateFormatString(true).Trim().Trim(stripParenth); 00458 this.TBValidFrom.Text = this.SelectedRestriction.ValidFrom.ToString(format); 00459 this.TBValidUntil.Text = this.SelectedRestriction.ValidUntil.ToString(format); 00460 } 00461 00462 //UI.Common.UserManagement.InitializeRegionsList(this.DDLdmregion, this.SelectedRole); 00463 //UI.Common.UserManagement.InitializeRegionsListWithEmptyRow(this.DDLdmregion, this.SelectedRole); 00464 UI.Common.UserManagement.InitializeRegionsListWithEmptyRow(this.DDLdmregion, null); 00465 00466 if (this.CurrentPageMode == PageMode.editUserPerm) 00467 this.SetRegionSelection(this.SelectedRestriction); 00468 00469 //UI.Common.UserManagement.InitializeDistrictsList(this.DDLdmdistrict, 00470 // this.SelectedRegion.Name); 00471 UI.Common.UserManagement.InitializeDistrictsListWithEmptyRow(this.DDLdmdistrict, 00472 this.DDLdmregion.SelectedValue); 00473 if(this.CurrentPageMode == PageMode.editUserPerm) 00474 this.SetDistrictSelection(this.SelectedRestriction); 00475 00476 UI.Common.UserManagement.InitializeFacilitiesList(this.DDLdmfacility, 00477 this.SelectedRegion.Name, 00478 this.SelectedDistrict.Name); 00479 this.DDLdmfacility.Items.Insert(0, new ListItem(string.Empty)); 00480 00481 if (this.CurrentPageMode == PageMode.editUserPerm) 00482 this.SetFacilitySelection(this.SelectedRestriction); 00483 00484 UI.Common.UserManagement.InitializePracticesListPlusEmptyRow(this.DDLpractice); 00485 00486 if (this.CurrentPageMode == PageMode.editUserPerm) 00487 this.SetPracticeSelection(this.SelectedRestriction); 00488 } 00489 00490 private void SetPracticeSelection(MessageBoxRestriction mbr) 00491 { 00492 if (mbr != null && this.DDLpractice.Items.Contains(new ListItem(mbr.PracticeName))) 00493 { 00494 this.DDLpractice.SelectedValue = mbr.PracticeName; 00495 } 00496 } 00497 00503 private void SetRegionSelection(MessageBoxRestriction mbr) 00504 { 00505 if (mbr != null 00506 && this.DDLdmregion.Items.Contains(new ListItem(mbr.RegionName))) 00507 { 00508 this.DDLdmregion.SelectedValue = mbr.RegionName; 00509 } 00510 } 00511 00517 private void SetDistrictSelection(MessageBoxRestriction mbr) 00518 { 00519 if (mbr != null 00520 && this.DDLdmdistrict.Items.Contains(new ListItem(mbr.DistrictName))) 00521 { 00522 this.DDLdmdistrict.SelectedValue = mbr.DistrictName; 00523 } 00524 } 00525 00531 private void SetFacilitySelection(MessageBoxRestriction mbr) 00532 { 00533 if (mbr != null 00534 && this.DDLdmfacility.Items.Contains(new ListItem(mbr.FacilityName))) 00535 { 00536 this.DDLdmfacility.SelectedValue = mbr.FacilityName; 00537 } 00538 } 00539 00544 private bool AddNewMessageBoxRestriction() 00545 { 00546 if (this.SelectedUser != null) 00547 { 00548 string validationMessage = string.Empty; 00549 bool success = true;// = this.ValidateNewDataRole(this.TXTrolename.Text, ref validationMessage); 00550 00551 if (success) 00552 { 00553 MessageBoxRestriction newMbr = new MessageBoxRestriction(); 00554 newMbr.Region = this.SelectedRegion; 00555 newMbr.District = this.SelectedDistrict; 00556 newMbr.Facility = this.SelectedFacility; 00557 newMbr.Practice = this.SelectedPractice; 00558 00559 try 00560 { 00561 newMbr.ValidFrom = DateTime.Parse(this.TBValidFrom.Text); 00562 newMbr.ValidUntil = DateTime.Parse(this.TBValidUntil.Text); 00563 } 00564 catch (Exception) 00565 { 00566 00567 success = false; 00568 } 00569 00570 if(success) 00571 success = ApplicationLogicLayer.UserManagement.saveMessageboxRestriction(this.SelectedUser, newMbr, ref validationMessage); 00572 00573 00574 if (success) 00575 { 00576 this.CurrentPageMode = PageMode.viewUserPerm; 00577 00578 //this.SavedDataRoleSelection = this.TXTrolename.Text; 00579 //UI.Common.UserManagement.InitializeDataRolesListBox(this.LBdmrolename, this.SavedDataRoleSelection); 00580 this.EnableDisableControls(); 00581 this.InitializeGridView(); 00582 } 00583 } 00584 00585 if (validationMessage == null || validationMessage == "") 00586 validationMessage = RAIS.UI.Common.Constants.MESSAGEBOX_RESTRICTION_ADDED; 00587 00588 00589 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult, 00590 validationMessage, 00591 success); 00592 return success; 00593 } 00594 else 00595 { 00596 // no user selected error 00597 return false; 00598 } 00599 } 00600 00605 private bool EditMessageBoxRestriction() 00606 { 00607 if (this.SelectedUser != null) 00608 { 00609 string validationMessage = string.Empty; 00610 bool success = true;// = this.ValidateNewDataRole(this.TXTrolename.Text, ref validationMessage); 00611 00612 if (success) 00613 { 00614 MessageBoxRestriction mbr = this.SelectedRestriction; 00615 mbr.Region = this.SelectedRegion; 00616 mbr.District = this.SelectedDistrict; 00617 mbr.Facility = this.SelectedFacility; 00618 mbr.Practice = this.SelectedPractice; 00619 00620 try 00621 { 00622 mbr.ValidFrom = DateTime.Parse(this.TBValidFrom.Text); 00623 mbr.ValidUntil = DateTime.Parse(this.TBValidUntil.Text); 00624 } 00625 catch (Exception) 00626 { 00627 00628 success = false; 00629 } 00630 00631 00632 success = ApplicationLogicLayer.UserManagement.editMessageboxRestriction(this.SelectedUser, mbr, ref validationMessage); 00633 00634 if (success) 00635 { 00636 this.CurrentPageMode = PageMode.viewUserPerm; 00637 00638 //this.SavedDataRoleSelection = this.TXTrolename.Text; 00639 //UI.Common.UserManagement.InitializeDataRolesListBox(this.LBdmrolename, this.SavedDataRoleSelection); 00640 this.EnableDisableControls(); 00641 this.InitializeGridView(); 00642 } 00643 } 00644 00645 if (validationMessage == null || validationMessage == "") 00646 validationMessage = RAIS.UI.Common.Constants.MESSAGEBOX_RESTRICTION_EDITED; 00647 00648 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult, 00649 validationMessage, 00650 success); 00651 return success; 00652 } 00653 else 00654 { 00655 // no user selected error 00656 return false; 00657 } 00658 } 00659 00664 private bool DeleteMessageBoxRestriction() 00665 { 00666 if (this.SelectedUser != null) 00667 { 00668 string validationMessage = string.Empty; 00669 bool success = true;// = this.ValidateNewDataRole(this.TXTrolename.Text, ref validationMessage); 00670 00671 if (success) 00672 { 00673 if (success) 00674 { 00675 00676 MessageBoxRestriction mbr = this.SelectedRestriction; 00677 00678 success = ApplicationLogicLayer.UserManagement.deleteMessageboxRestriction(this.SelectedUser, mbr, ref validationMessage); 00679 } 00680 00681 if (success) 00682 { 00683 this.CurrentPageMode = PageMode.viewUserPerm; 00684 00685 //this.SavedDataRoleSelection = this.TXTrolename.Text; 00686 //UI.Common.UserManagement.InitializeDataRolesListBox(this.LBdmrolename, this.SavedDataRoleSelection); 00687 this.EnableDisableControls(); 00688 this.InitializeGridView(); 00689 } 00690 } 00691 00692 if (validationMessage == null || validationMessage == "") 00693 validationMessage = RAIS.UI.Common.Constants.MESSAGEBOX_RESTRICTION_DELETED; 00694 00695 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult, 00696 validationMessage, 00697 success); 00698 return success; 00699 } 00700 else 00701 { 00702 // no user selected error 00703 return false; 00704 } 00705 } 00706 00707 #endregion 00708 00709 #region Properties 00710 00714 private MessageBoxRestrictions MessageBoxRestrictions 00715 { 00716 get 00717 { 00718 MessageBoxRestrictions mbr = null; 00719 if (this.LBselecteduser.SelectedIndex != -1) 00720 { 00721 if(this.DDLyesNo.SelectedIndex == 0) 00722 mbr = UI.Common.UserManagement.getActiveMessageBoxRestrictionsForUser(this.SelectedUser, DateTime.Now); 00723 else 00724 mbr = UI.Common.UserManagement.getActiveMessageBoxRestrictionsForUser(this.SelectedUser); 00725 } 00726 00727 return mbr; 00728 } 00729 } 00730 00731 private MessageBoxRestriction SelectedRestriction 00732 { 00733 get 00734 { 00735 if (this.MessageBoxRestrictions != null && this.GVuserpermissions.SelectedIndex != -1 && this.GVuserpermissions.SelectedIndex < this.MessageBoxRestrictions.Count) 00736 return this.MessageBoxRestrictions[this.GVuserpermissions.SelectedIndex]; 00737 else 00738 return null; 00739 } 00740 } 00741 00749 PageMode CurrentPageMode 00750 { 00751 get 00752 { 00753 if (this.Session[UI.Common.Constants.USER_PERM_EDIT_MODE_TAG] != null) 00754 { 00755 return (PageMode)this.Session[UI.Common.Constants.USER_PERM_EDIT_MODE_TAG]; 00756 } 00757 else 00758 return PageMode.viewUserPerm; 00759 } 00760 set 00761 { 00762 string message; 00763 switch (value) 00764 { 00765 case PageMode.addUserPerm: message = RAIS.UI.Common.Constants.ADDING_NEW_USER_PERM; break; 00766 case PageMode.editUserPerm: message = RAIS.UI.Common.Constants.EDITING_EXISTING_USER_PERM; break; 00767 00768 default: 00769 this.Session[RAIS.UI.Common.Constants.USER_PERM_TEMPORARY_TAG] = null; 00770 message = string.Empty; 00771 break; 00772 } 00773 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult, message, true); 00774 this.Session[UI.Common.Constants.USER_PERM_EDIT_MODE_TAG] = value; 00775 this.EnableDisableControls(); 00776 } 00777 } 00781 private UserData SelectedUser 00782 { 00783 get 00784 { 00785 try 00786 { 00787 UserData userData = ApplicationLogicLayer.UserManagement.GetUserData(this.LBselecteduser.SelectedValue); 00788 this.Session[RAIS.UI.Common.Constants.SELECTED_USER_TAG] = userData; 00789 return userData; 00790 } 00791 catch (Exception) 00792 { 00793 return null; 00794 } 00795 } 00796 } 00800 private Region SelectedRegion 00801 { 00802 get 00803 { 00804 Regions regions = (Regions)this.Session[RAIS.UI.Common.Constants.REGIONS_TAG]; 00805 if (regions != null) 00806 if (this.DDLdmregion.SelectedValue == string.Empty) 00807 return new Region(); 00808 else 00809 return regions[this.DDLdmregion.SelectedValue]; 00810 else 00811 return null; 00812 } 00813 } 00817 private District SelectedDistrict 00818 { 00819 get 00820 { 00821 Districts districts = ApplicationLogicLayer.UserManagement.GetDistrictsByRegion(this.SelectedRegion); 00822 if (districts != null) 00823 if (this.DDLdmdistrict.SelectedValue == string.Empty) 00824 return new District(); 00825 else 00826 return districts[this.DDLdmdistrict.SelectedValue]; 00827 else 00828 return null; 00829 } 00830 } 00834 private Facility SelectedFacility 00835 { 00836 get 00837 { 00838 Region selectedRegion = this.SelectedRegion; 00839 District selectedDistrict = this.SelectedDistrict; 00840 Facilities facilities = ApplicationLogicLayer.UserManagement.GetFacilitiesByRegionAndDistrict(selectedRegion, selectedDistrict); 00841 if (this.DDLpractice.SelectedValue != null && 00842 this.DDLpractice.SelectedValue != "" && 00843 (this.DDLdmregion.SelectedValue == null || this.DDLdmregion.SelectedValue.Equals(String.Empty)) && 00844 (this.DDLdmdistrict.SelectedValue == null || this.DDLdmdistrict.SelectedValue.Equals(String.Empty))) 00845 { 00846 return RAIS.ApplicationLogicLayer.UserManagement.Facilities[RAIS.Common.Constants.ALL_FACILITIES_UNKNOWN]; 00847 } 00848 if (facilities != null) 00849 { 00850 if (this.DDLdmfacility.SelectedValue == string.Empty) 00851 return new Facility(); 00852 else 00853 return facilities[this.DDLdmfacility.SelectedValue]; 00854 } 00855 else 00856 { 00857 return null; 00858 } 00859 } 00860 } 00861 00862 private Practice SelectedPractice 00863 { 00864 get 00865 { 00866 Practices practices = ApplicationLogicLayer.UserManagement.Practices; 00867 if (practices != null) 00868 if (this.DDLpractice.SelectedValue == string.Empty) 00869 return null; 00870 else 00871 return practices[this.DDLpractice.SelectedValue]; 00872 else 00873 return null; 00874 } 00875 } 00876 00880 protected UserData CurrentUser 00881 { 00882 get { return (UserData)this.Session[UI.Common.Constants.CURRENT_USER_TAG]; } 00883 } 00884 #endregion Properties 00885 } 00886 }